package com.jml.递归;


/**
 * @author:jml
 * @date: 2019/5/16 13:56
 * @description：
 */
public class 递归求数组的和 {


    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        int sum = sum(arr, 0);
        System.out.println(sum);
    }

    private static int sum(int[] arr,int l) {
        if(l==arr.length){
            return 0;
        }
        return arr[l]+sum(arr,l+1);
    }


}
